package com.aishang.javacv.lab.config;

import lombok.Data;
import org.apache.commons.dbcp2.BasicDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

@Data
@Configuration
public class DataSourceConfig {
    @Value("${spring.datasource.driver-class-name}")
    private String driver;
    @Value("${spring.datasource.url}")
    private String url;

    @Bean
    public DataSource dataSource()
    {
        BasicDataSource bean = new BasicDataSource();
        bean.setDriverClassName(driver);
        bean.setUrl(url);
        return bean;
    }
}
